public class Test <T extends Comparable<T>>{
    public T findMax(T[] array){
        T max=array[0];
        for(int i=1;i< array.length;i++){
            if(array[i].compareTo(max)>0){
                max=array[i];
            }
        }
        return max;
    }
    public static void main(String[] args) {

        Integer[]array={1,2,3,4,5,6,7};
        Integer x=Alg3.findMax(array);
        System.out.println(x);}
    public static void main2(String[] args) {
        Alg2 alg2=new Alg2();
        Integer[]array={1,2,3,4,5,6,7};
        Integer x=alg2.findMax(array);
        System.out.println(x);
    }
    public static void main1(String[] args) {
        Test<Integer> test=new Test<>();
        Integer[]array={1,2,3,4,5,6,7};
        Integer x=test.findMax(array);
        System.out.println(x);
    }
}
class Alg2{
    public <T extends Comparable<T>> T findMax(T[] array){

            T max=array[0];
            for(int i=1;i< array.length;i++){
                if(array[i].compareTo(max)>0){
                    max=array[i];
                }
            }
            return max;
        }
    }
class   Alg3{
    public static <T extends Comparable<T>> T findMax(T[] array){

        T max=array[0];
        for(int i=1;i< array.length;i++){
            if(array[i].compareTo(max)>0){
                max=array[i];
            }
        }
        return max;
    }
}

